<template>
  <div class="ChildPage TablePage" v-loading="loading">
    <vb-page ref="page" @onTableSelection="doSelect">

      <template #table-syncInfo="scope">
        <el-tag :type="scope && scope.row && scope.row.syncInfo === true? 'success': 'info'">{{scope && scope.row && scope.row.syncInfo === true? '成功': '失败' }}</el-tag>
      </template>
      <template #table-handle-prepend="scope">
        <el-button size="mini" type="text" icon="el-icon-edit" @click="syncStorageOut(scope.row.goodsdocNo)">重传</el-button>
      </template>
    </vb-page>
  </div>

</template>

<script>

export default {
  data() {
    return {
      loading:false,
      selection: null,
      selectionLength:0,
      stockLoading: false,
      reloadStock: false,
    }
  },
  components: {

  },
  methods: {
    async syncStorageOut (goodsdocNo){
      try {
        let res = await this.callApi('sync_storage_out',{goodsdocNo: goodsdocNo})
        if(!res.res){
          return
        }
        this.$message.success('重传完成,请查看')
        this.$refs.page.reload()
      }finally {
        this.loading = false
      }
    },


    doSelect(data) {
      this.selection = data
      this.selectionLength = this.selection.length;
      this.selectCount=0
      for (var i=0;i<this.selectionLength;i++){
        this.selectCount+=data[i].count
      }
      this.selectCount = parseFloat(this.selectCount).toFixed(2)
    }
  }
}
</script>

<style scoped>

</style>
